<template>
	<view class="profile">
		<!-- 个人信息 -->
		<view class="profile_info" >
			<view class="infoleft">
				<view class="info_img">
					<image :src="userInfo.img ? userInfo.img :BASE_IMG_URL+'headImg.png'"  mode="scaleToFill"></image>
				</view>
				<view class="info_con">
					<view>{{userInfo.name}}<text>{{userInfo.post?userInfo.post:''}}</text></view>
					<view>{{userInfo.mobile}}</view>
				</view>
			</view>
			<image :src="BASE_IMG_URL+'lxr_set.svg'" @click="toSet" class="rightimg" ></image>
		</view>
		
		<view class="warpbox">
			<view class="fun_box_fir">
				<view class="fun_fir_1" @click="remind">
					<view class="fun_tip" v-if="info && info.leads && info.leads.count != 0">{{info && info.leads.count}}</view>
					<image :src="BASE_IMG_URL+'index_new_22.svg'" mode="scaleToFill"></image>
					<view>通知</view>
				</view>
				<view class="fun_fir_1" @click="jumpDeal">
					<view class="fun_tip" v-if="info && info.agent && info.agent.count != 0">{{info && info.agent.count}}</view>
					<image :src="BASE_IMG_URL+'index_new_23.svg'" mode="scaleToFill"></image> 
					<view>待办</view>
				</view>
				<view class="fun_fir_1" @click="toApproveManage">
					<view class="fun_tip" v-if="info && info.examine && info.examine.count != 0">{{info && info.examine.count}}</view>
					<image :src="BASE_IMG_URL+'index_new_7.png'" mode="scaleToFill"></image> 
					<view>审批</view>
				</view>
			</view>
		</view>
		<!-- 在线联系 -->
		<view class="link_box" v-if="false">
			<view class="link_left">
				<image src="/static/kefu.jpg" class="logoimg" mode="scaleToFill"></image>
				<view class="link_cen">
					<view class="label">在线咨询</view>
					<view class="text">添加客服进行咨询</view>
				</view>
			</view>
			<view class="link_btn" @click="toCopy">复制微信号</view>
		</view>
		
		<view class="warpbox">
			<view class="warptitle">客户管理</view>
			<view class="fun_box">
				<view class="fun_fir" @click="toWaterCustomer">
					<image :src="BASE_IMG_URL+'index_new_24.svg'" mode="scaleToFill"></image>
					<view>公海客户</view>
				</view>
				<view class="fun_fir" @click="toIndexClue">
					<image :src="BASE_IMG_URL+'index_new_26.svg'" mode="scaleToFill"></image> 
					<view>线索</view>
				</view>
				<view class="fun_fir" @click="toIndexCustomer">
					<image :src="BASE_IMG_URL+'index_new_25.svg'" mode="scaleToFill"></image>
					<view>客户</view>
				</view>
				<view class="fun_fir" @click="toIndexContract">
					<image :src="BASE_IMG_URL+'index_new_5.png'" mode="scaleToFill"></image>
					<view>合同</view>
				</view>
				<view class="fun_fir" @click="toNears">
					<image :src="BASE_IMG_URL+'index_new_9.png'" mode="scaleToFill"></image>
					<view>附近客户</view>
				</view>
				<view class="fun_fir" @click="toProductList">
					<image :src="BASE_IMG_URL+'index_new_11.png'" mode="scaleToFill"></image>
					<view>产品</view>
				</view>
			</view>
		</view>
		<view class="warpbox">
			<view class="warptitle">办公</view>
			<view class="fun_box">
				<view class="fun_fir" @click="workreport">
					<image :src="BASE_IMG_URL+'index_new_12.png'" mode="scaleToFill"></image>
					<view>工作报告</view>
				</view>
				<view class="fun_fir" @click="affiche">
					<image :src="BASE_IMG_URL+'index_new_19.png'" mode="scaleToFill"></image>
					<view>公告</view>
				</view>
				<view class="fun_fir" @click="toIndexRecord">
					<image :src="BASE_IMG_URL+'index_new_7.png'" mode="scaleToFill"></image>
					<view>跟进记录</view>
				</view>
				<view class="fun_fir" @click="jumpSign">
					<image :src="BASE_IMG_URL+'index_new_12.png'" mode="scaleToFill"></image>
					<view>签到记录</view>
				</view>
				<view class="fun_fir" @click="toClientele">
					<image :src="BASE_IMG_URL+'index_new_21.svg'" mode="scaleToFill"></image>
					<view>重点关注</view>
				</view>
				<view class="fun_fir" @click="agendar">
					<image :src="BASE_IMG_URL+'index_new_17.png'" mode="scaleToFill"></image>
					<view>日程</view>
				</view>
				<view class="fun_fir" @click="approve">
					<image :src="BASE_IMG_URL+'index_new_20.png'" mode="scaleToFill"></image>
					<view>办公</view>
				</view>
			</view>
		</view>
		<view class="warpbox">
			<view class="warptitle">财务</view>
			<view class="fun_box">
				<view class="fun_fir" @click="toPayPlan">
					<image :src="BASE_IMG_URL+'index_new_18.png'" mode="scaleToFill"></image>
					<view>回款计划</view>
				</view>
				<view class="fun_fir" @click="toPayment">
					<image :src="BASE_IMG_URL+'index_new_23.svg'" mode="scaleToFill"></image>
					<view>回款单</view>
				</view>
				<view class="fun_fir" @click="toCostList">
					<image :src="BASE_IMG_URL+'feiyong1.png'" mode="scaleToFill"></image>
					<view>费用管理</view>
				</view>
			</view>
		</view>
		<view class="warpbox">
			<view class="warptitle">统计</view>
			<view class="fun_box">
				<!-- <view class="fun_fir" @click="toReturnedMoney">
					<image :src="BASE_IMG_URL+'index_new_6.png'" mode="scaleToFill"></image>
					<view>回款统计</view>
				</view> -->
				<view class="fun_fir" @click="achievementObjectClick">
					<image :src="BASE_IMG_URL+'index_new_8.png'" mode="scaleToFill"></image> 
					<view>业绩完成度</view>
				</view>
				<view class="fun_fir" @click="collectClick">
					<image :src="BASE_IMG_URL+'index_new_11.png'" mode="scaleToFill"></image>
					<view>销售简报</view>
				</view>
				<view class="fun_fir" @click="achieveRank">
					<image :src="BASE_IMG_URL+'index_new_10.png'" mode="scaleToFill"></image>
					<view>排行榜</view>
				</view>
				
			</view>
		</view>
		<view class="warpbox" v-if="roleType == 1 || roleType == 2">
			<view class="warptitle">管理</view>
			<view class="fun_box">
				<view class="fun_fir" @click="jumpStaffList" v-if="roleType == 1 || roleType == 2">
					<image :src="BASE_IMG_URL+'index_new_23.svg'" mode="scaleToFill"></image>
					<view>员工列表</view>
				</view>
				<view class="fun_fir" @click="toTarget">
					<image :src="BASE_IMG_URL+'index_new_7.png'" mode="scaleToFill"></image>
					<view>业绩目标</view>
				</view>
			</view>
		</view>
		<!-- 底部导航 -->
		<uniTabbar v-if="tipNumber || tipNumber==0" :tipNumber="tipNumber"></uniTabbar>
	</view>
</template>
	 
<script>
	import uniTabbar from '@/components/tabbar/tabbar.vue'
	import {pageJumps} from "./profile_page_iumps.js";
	import { netGetUserInfo } from '@/api/index.js'
	import { netAgentList } from '@/api/clues.js'
	import { BASE_IMG_URL } from '@/util/api.js'
	import * as crmjs from "@/pagesA/crm/crm_page_jumps.js";
	import * as newsjs from "@/pages/news/news_page_jumps.js";
	
	export default {
		mixins:[pageJumps,crmjs.pageJumps,crmjs.statisticalPageJumps,newsjs.pageJumps],
		components:{
			uniTabbar
		},
		data() {
			return {
				userInfo:{},
				roleType:1,
				rules:[],
				tipNumber:null,
				BASE_IMG_URL:BASE_IMG_URL,
				info:{}
			}
		},
		onShow() {
			this.roleType = uni.getStorageSync('roleType')
			this.rules = uni.getStorageSync('rules')
			
			this.getTip()
		},
		methods: {
			getTip(){
				netAgentList().then(res=>{
					uni.setStorageSync('token',res.data.userinfo.token)
					uni.setStorageSync('roleType',res.data.userinfo.role_type)
					uni.setStorageSync('rules',res.data.userinfo.rules)
					this.info = res.data
					this.tipNumber = res.data.total
					this.getInfo()
				})
			},
			getInfo() {
				netGetUserInfo().then(res=>{
					this.userInfo = res.data
				})
			},
			//产品列表
			toProductList() {
				uni.navigateTo({
					url:'/pagesA/product/index'
				})
			},
			//员工列表 
			jumpStaffList() {
				uni.navigateTo({
					url:'/pagesA/profile/staff/stafflist/index'
				})
			},
			//审核  员工  列表
			jumpExamineStaff() {
				uni.navigateTo({
					url:'/pagesA/profile/staff/examinestaff/index'
				})
			},
			// 企业信息
			toEnterprise(id) {
				console.log(id,'id')
				uni.navigateTo({
					url: '/pagesA/profile/enterpriseInfo/enterpriseInfo?id?' +id
				})
			},
			//设置
			toSet(){
				uni.navigateTo({
					url:'/pagesA/profile/set'
				})
			},
			//回款列表
			toPayment() {
				uni.navigateTo({
					url:'/pagesA/payment/index'
				})
			},
			toPayPlan() {
				uni.navigateTo({
					url:'/pagesA/payplan/index'
				})
			},
			//费用管理
			toCostList() {
				uni.navigateTo({
					url:'/pagesA/cost/index'
				})
			},
			//审批管理
			toApproveManage() {
				uni.navigateTo({
					url:'/pagesA/work/approvelManage/index'
				})
			},
			//业绩目标
			toTarget() {
				if (this.roleType == 2 && (this.rules.indexOf('all') != -1 || this.rules.indexOf('2') != -1)) {
					uni.navigateTo({
						url: '/pagesA/crm/salesTarget/salesTarget',
					})
				} else {
					uni.navigateTo({
						url: '/pagesA/crm/salesTarget/myTarget',
					})
				}
			},
			//业绩排名
			achieveRank() {
				uni.navigateTo({
					url:'/pagesA/crm/statisticalFrom/achieveRank'
				})
			},
			//复制微信号 添加客服
			toCopy() {
				uni.setClipboardData({
					data:'lcq406337111',
					success:(res)=>{
						uni.showToast({
							title:'微信号已复制',
							icon:'none'
						})
					},
					fail:(err)=>{
						
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 在线联系
	.link_box{
		width:702rpx;
		box-sizing: border-box;
		background:#fff;
		border-radius: 20rpx;
		margin:0 auto 30rpx;
		padding:30rpx;
		box-shadow: 1rpx 1rpx 10rpx rgba(0,0,0,0.1);
		display: flex;
		justify-content: space-between;
		align-items: center;
		.link_left{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			.logoimg{
				width:140rpx;
				height:140rpx;
				margin-right:24rpx;
			}
			.link_cen{
				.label{
					font-size:28rpx;
					color:#333;
				}
				.text{
					font-size:26rpx;
					color:#999;
					margin-top:10rpx;
				}
			}
		}
		.link_btn{
			width:160rpx;
			height:60rpx;
			border-radius: 30rpx;
			background:$uni-text-color;
			color:#fff;
			text-align: center;
			line-height: 60rpx;
			font-size:24rpx;
		}
	}
	
	.fun_box_fir{
		display: flex;
		justify-content: space-around;
		align-items: center;
		.fun_fir_1{
			flex-shrink: 0;
			background:#fff;
			border-radius: 10rpx;
			text-align: center;
			width:142rpx;
			height:115rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size:24rpx;
			color:#000;
			position: relative;
			.fun_tip{
				position: absolute;
				right:15rpx;
				top:-10rpx;
				background:#F13E27;
				color:#fff;
				font-size:26rpx;
				width:40rpx;
				height:40rpx;
				border-radius: 50%;
				text-align: center;
				line-height: 40rpx;
				z-index:2;
			}
			image{
				width:50rpx;
				height:50rpx;
				margin-bottom:15rpx;
			}
		}
	}
	.message_num {
		width: 20rpx;
		height: 20rpx;
		border-radius: 20rpx;
		color: #fff;
		position: relative;
		top: 0;
		right: 0;
	}
	.color{
		background: #fff;
	}
	.colore{
		background: #f00;
	}
	.warpbox{
		width:702rpx;
		box-sizing: border-box;
		background:#fff;
		border-radius: 20rpx;
		margin:0 auto 30rpx;
		padding:30rpx;
		box-shadow: 1rpx 1rpx 10rpx rgba(0,0,0,0.1);
		.warptitle{
			font-size:26rpx;
			color:#333;
			margin-bottom:30rpx;
		}
		.fun_box{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			flex-wrap:wrap;
			.fun_fir{
				flex-shrink: 0;
				background:#fff;
				border-radius: 10rpx;
				text-align: center;
				width:142rpx;
				height:115rpx;
				margin-right:24rpx;
				margin-bottom:24rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				font-size:24rpx;
				color:#000;
				&:nth-child(4n){
					margin-right:0;
				}
				image{
					width:50rpx;
					height:50rpx;
					margin-bottom:15rpx;
				}
			}
			
		}
	}
.profile {
	// 个人信息
	.profile_info {
		background-color: #fff;
		display: flex;
		padding: 50rpx;
		border-bottom: 1rpx solid #EAEAEA;
		margin-bottom: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.infoleft{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			.info_img {
				width: 150rpx;
				image {
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
				}
			}
		}
		
		.info_con {
			flex: 1;
			margin-top: 20rpx;
			:first-child {
				font-size: 28rpx;
				margin-bottom: 15rpx;
			}
			text {
				font-size: 24rpx;
				margin-left: 10rpx;
				color: #999;
			}
			:last-child {
				color: #999;
			}
		}
		.rightimg{
			width:40rpx;
			height:40rpx;
		}
	}
	
}

.iconfont{
	padding-top: 4px;
}
.lxs_font{
	font-size: 14px;
}
</style>
